<form id="listForm" method="post">
<input type="hidden" id="formId" name="formId" value="#(formId)" />
<!-- 数据表格 -->
<div class="table-box">
	<!--工具栏-->
	<div class="pull-left">
		<div class="form-group form-inline">
			<div class="btn-group">
				<button type="button" class="btn btn-default" id="addButton" formId="#(formId)"><i class="fa fa-file-o"></i> 新建</button>
				<button type="button" class="btn btn-default disabled" id="deleteButton" url="#(base)/admin/form_data/delete?formId=#(formId)"><i class="fa fa-trash-o"></i> 删除</button>
				<button type="button" class="btn btn-default" id="localRefreshButton"><i class="fa fa-refresh"></i> 刷新</button>
			</div>
		</div>
	</div>
	<!--工具栏/-->
	<!--数据列表-->
	<table id="listTable"
		class="table table-bordered table-striped table-hover dataTable">
		<thead>
			<tr>
				<th width="40"><input type="checkbox" id="selectAll" /></th>
				<th>ID</th>
				#for(formField : formFields)
                <th>#(formField.alias)</th>
                #end
                <th>操作</th>
			</tr>
		</thead>
		<tbody id="listTr">
			#for(formData : page.list)
			<tr>
				<td><input type="checkbox" name="ids" value="#(formData.id)" /></td>
				<td>#(formData.id)</td>
				#for(formField : formFields)
				<td>#(formData.get(formField.name))</td>
				#end
				<td>
					<button type="button" class="btn bg-olive btn-xs editButton" formDataId="#(formData.id)" formId="#(formId)">编辑</button>
				</td>
			</tr>
			#end
		</tbody>
	</table>
	<!--数据列表/-->
</div>
<!-- 数据表格 /-->
<!-- .box-footer-->
#page(pageNumber = page.pageNumber,totalPages = page.totalPage,pattern ="") 
#include("../include/page.html") 
#end
<!-- /.box-footer-->
</form>
<script type="text/javascript">
var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch-small'));
elems.forEach(function(html) {
  var switchery = new Switchery(html, { size: 'small' });
});
$().ready(function() {
	
	// 表单提交
	$("#listForm").submit(function(){
		loadData(getFormData($("#listForm")));
		return false;
	});
	
	// 刷新
	$("#localRefreshButton").on("click",function(){
		$("#listForm").submit();
	});

});
</script>
